<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新建流程步骤</title>
<import type="css" file="css.workform" />
<import type="js" file="js.jquery" />
<SCRIPT language=javascript>
function func_insert()
{
	$("select[name=select2] option").each(function(){
		if( $(this).attr("selected") ){
			if($("select[name=select1] option").size() == 0){
				var val = $(this).val();
				var text = $(this).text();
				$(this).remove();
				$("select[name=select1]").append("<option value="+val+" selected >"+text);
			}else{
				alert("下一步骤只能选择一个！");
			}
		}
	});
}
function func_delete()
{
	$("select[name=select1] option").each(function(){
		if( $(this).attr("selected") ){
			var val = $(this).val();
			var text = $(this).text();
			$(this).remove();
			$("select[name=select2]").append("<option value="+val+" selected >"+text);
		}
	});
}
function func_select_all1()
{
	$("select[name=select1] option").each(function(){
		$(this).attr("selected",true);
	});
}
function func_select_all2()
{
	$("select[name=select2] option").each(function(){
		$(this).attr("selected",true);
	});
}
function func_up()
{
	var so = $("select[name=select1] option:selected");
    if(so.get(0).index > 0){  
	    so.each(function(){
	    	$(this).prev().before($(this)); 
	    });  
    } 
}
function func_down()
{
	var so = $("select[name=select1] option:selected");
    if( so.get(0).index < ($("select[name=select1] option").size()-1) ){  
	    so.each(function(){
	    	$(this).insertAfter($(this).next('option')); 
	    });  
    } 
    
}
function ChenckForm()
{
	if( $("select[name=select1] option").size() != 1 ){
		alert("下一步不能为空且只能选择一个！");return false;
	}
	var select1 = $("select[name=select1] option").val();
	$("input[name=proc_to]").attr("value",select1);
	var proc_no = $("input[name=proc_no]").val();
	if( proc_no == "" || !/^[1-9]*[1-9][0-9]*$/.test(proc_no)){
		alert("序号不能为空且只能是数字");return false;
	}
	if( $("input[name=proc_name]").val() == "" ){
		alert("步骤名称不能为空！");return false;
	}
}
</SCRIPT>
</head>
<body>
<table border="0" width="100%" cellspacing="0" cellpadding="3" class="small">
<tr>
	<td class="Big"><img src="__PUBLIC__/images/edit.gif" WIDTH="22" HEIGHT="20" align="absmiddle"><span class="big3"> 新建流程步骤</span><br>
	</td>
</tr>
</table>

<form action="__APP__/WorkFlowSys/flow_process_insert" method="post" name="form1" onSubmit="return ChenckForm();">
<table border="0" width="90%" cellpadding="2" cellspacing="1" align="center" bgcolor="#000000" class="small">
	<tr>
		<td nowrap class="TableContent">序号：</td>
		<td class="TableData">
			<input type="text" name="proc_no" size="2" maxlength="10" class="BigInput"  value="{$proc_no}"><font color="red">为数字，且不可与其他步骤排序号重复</font>
		</td>
	</tr>
	<tr>
		<td nowrap class="TableContent">步骤名称：</td>
		<td class="TableData">
			<input type="text" name="proc_name" size="30" maxlength="100" class="BigInput" value="">
		</td>
	</tr>
	<tr>
		<td nowrap class="TableContent">下一步骤：</td>
		<td class="TableData">
		只能选择一个步骤<br>
		<table width="500" border="0" cellspacing="0" cellpadding="3" bordercolorlight="#000000" bordercolordark="#FFFFFF" class="small">
		<tr bgcolor="#CCCCCC">
			<td align="center">排序</td>
			<td align="center"><b>下一步骤</b></td>
			<td align="center">选择</td>
			<td align="center" valign="top"><b>备选步骤</b></td>
		</tr>
		<tr>
			<td align="center" bgcolor="#999999">
				<input type="button" class="SmallInput" value=" ↑ " onclick="func_up();">
				<br><br>
				<input type="button" class="SmallInput" value=" ↓ " onclick="func_down();">
			</td>
			<td valign="top" align="center" bgcolor="#CCCCCC">
			<select  name="select1" ondblclick="func_delete();" MULTIPLE style="width:200px;height:200px">
				<if condition="$data_proc_select eq 0">
					<option value="0">[结束流程]
				<else />
					<option value="{$data_proc_select.proc_no}">{$data_proc_select.proc_no}、{$data_proc_select.proc_name}
				</if>
		    </select>
			<input type="button" value=" 全 选 " onclick="func_select_all1();" class="SmallInput">
			</td>
			<td align="center" bgcolor="#999999">
				<input type="button" class="SmallInput" value=" ← " onclick="func_insert();">
				<br><br>
				<input type="button" class="SmallInput" value=" → " onclick="func_delete();">
			</td>
			<td align="center" valign="top" bgcolor="#CCCCCC">
			<select  name="select2" ondblclick="func_insert();" MULTIPLE style="width:200px;height:200px">
			<volist name="data_proc_all" id="vo">
				<option value="{$vo.proc_no}">{$vo.proc_no}、{$vo.proc_name}
			</volist>
				<option value="0">[结束流程]
		    </select>
			<input type="button" value=" 全 选 " onclick="func_select_all2();" class="SmallInput">
			</td>
		</tr>
		</table>
		<input type="hidden" name="proc_to" size="20" class="BigInput" value="">
		</td>
	</tr>
	<tr align="center" class="TableControl">
		<td colspan="2" nowrap>
			<input type='hidden' value="{$type_id}" name="type_id">
			<input type="submit"  value="保存" class="BigButton" name="submit">&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button"  value="返回" class="BigButton" name="back" onClick="history.back();">
      </td>
	</tr>
</table>
</form>
</body>
</html>